package midone.exchangeskill.main.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import midone.exchangeskill.R;
import midone.exchangeskill.bean.IndexGoodsBean;

/**
 * Created by NekoNeko on 2016/12/20.
 */

public class MainGoodsListAdapter extends RecyclerView.Adapter {
    List<IndexGoodsBean.DataBean> mBeanList = new ArrayList<>();

    public List<IndexGoodsBean.DataBean> getBeanList() {
        return mBeanList;
    }

    public void setBeanList(List<IndexGoodsBean.DataBean> beanList) {
        mBeanList = beanList;
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_main_goods_list, parent, false);
        return new ViewHolder(itemView);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        ViewHolder viewHolder = (ViewHolder) holder;
        viewHolder.mGoodsName.setText(mBeanList.get(position).getTitle());

    }

    @Override
    public int getItemCount() {
        return mBeanList.size();
    }


    static class ViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.goods_image)
        ImageView mGoodsImage;
        @BindView(R.id.goods_name)
        TextView mGoodsName;

        public ViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
